package cn.design.realize.demo1;

/**
 * @author dlq
 * @description
 *      环境类,定义客户感兴趣的接口,持有当前状态的具体状态的实例(拥有States属性)，此外，他还定义了供外部调用者使用的状态模式的接口
 * @date 2020/10/12 9:46
 * @since 1.0
 */
public class Context {
    private State state;

    public Context(State state){
        this.state = state;
    }
    /**
     * @description 向外部(客户端提供的接口)
     * @param msg
     * @return void
     * @author dlq
     * @date 2020/10/12 9:49
     */
    public void execute(String msg){
        System.out.println(msg);
        state.handle();
    }

    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
    }
}
